<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/struts-tiles.tld" prefix="tiles" %>
<%@ taglib uri="/WEB-INF/vectrics.tld"    prefix="vectrics" %>

<%@ page import="org.vectrics.security.*" %>
<%@ page import="org.vectrics.user.*" %>
<%@ page import="org.vectrics.hibernate.*" %>
<%@ page import="org.vectrics.provider.*" %>
<%@ page import="java.util.Collection" %>
<%@ page import="com.hexacta.hrs.securitygroups.*" %>
<%@ page import="com.hexacta.hrs.services.securitygroups.*" %>

<vectrics:errors/>
<%@ page import="org.vectrics.struts.*" %>
<%
	Request vectricsRequest = HttpRequestConverter.convertRequest(request);

	Person authPerson = PrivilegeUtils.getAuthPerson(vectricsRequest);
	String newUserValue = request.getParameter("newUser");
	String userId = request.getParameter("userId");
	if (userId == null)
		userId = request.getParameter("user");
	String personId = userId;
	Person person = CoreServiceLocator.getPersonService().findPersonById(new Long(personId));
	String domainId = ThreadProperties.getDomain().getId().toString();
	boolean newUser = false;
	if (person.getUser().getUserName() == null) {
		newUser = true;
	}
	User user = person.getUser();
%>
<vectrics:userSummary personId="<%=personId%>" compact="true"/>

<html:form action="/admin/user/save" method="POST">
	<html:hidden property="userId"/>

<% if (newUser) {%>
	<input type="hidden" name="newUser" value="true">
<% } else { %>
	<input type="hidden" name="newUser" value="false">
<% } %>

	<vectrics:userGroupSelect personId="<%=personId%>" hidden="true" domainId="<%=domainId%>"/>
	
	<table width="100%">
		<tr>
			<td width="50%">
				<table cellpadding="4" cellspacing="1">
					<tr>
						<td valign="TOP" colspan="3"><h3><bean:message key="heading.user.basic.info"/></h3></td>
					</tr>
					<tr>
						<td valign="top" width="150" class="formBg1">
							<font class="formLabelClass"><bean:message key="prompt.user.name"/><b> *</b></font>
							<vectrics:errors property="userName"/>
						</td>
						<td valign="top" class="formBg1">
							<html:text property="userName" styleClass="formEditClass" maxlength="16"/>
						</td>
						<td></td>
					</tr>
					
					<tr>
						<td class="formBg2" valign="top" width="150"><font class="formLabelClass"><bean:message key="prompt.user.roles"/></font></td>
						
						<td class="formBg2" valign="top" width="150"><font class="formLabelClass">
							<logic:iterate name="userProfileForm" id="security" property="securityGroups">
								<html:multibox property="securityGroupsSelected">
   									<bean:write name="security"/> 
  								</html:multibox> 
								 	<bean:write name="security" /><br>
							</logic:iterate>
							
							</font>
						</td>
					</tr>
					
					
					<tr>
						<td valign="TOP" align="left"></td>
						<td valign="TOP" align="left">
							<vectrics:formButton elementId="ok.btn" code="button.ok" phraseCode="button.ok" value="submit" name="submit"/>
							&nbsp;
							<vectrics:formButton elementId="cancel.btn" code="button.cancel" phraseCode="button.cancel" value="cancel" name="cancel"/>						
						</td>
						<td></td>
					</tr>
				</table>
			</td>
		</tr>
	</table>
	

					
	
					
	
</html:form>
